package com.googlecode.npgame.simulation;

import java.util.ArrayList;
import java.util.List;

/**
 * Keeps total score statistics and scoring for each individual level.
 * 
 * @author Josh (joshbruning)
 */
public class TotalScore extends Score {

  private List<Score> levelScores;
  private int lastLevel;

  public TotalScore() {
    this.levelScores = new ArrayList<Score>();
    this.lastLevel = -1;
  }

  public void createLevel() {
    this.levelScores.add(new Score());
    this.lastLevel++;
  }

  @Override
  public void addElement(Element element, int oldFrameSize) {
    super.addElement(element, oldFrameSize);
    this.levelScores.get(this.lastLevel).addElement(element, oldFrameSize);
  }

  @Override
  public void addDuplicate(Element element) {
    super.addDuplicate(element);
    this.levelScores.get(this.lastLevel).addDuplicate(element);
  }

  @Override
  public void addInvalid(Element element) {
    super.addInvalid(element);
    this.levelScores.get(this.lastLevel).addInvalid(element);
  }

  @Override
  public void addFrame(Frame frame) {
    super.addFrame(frame);
    this.levelScores.get(this.lastLevel).addFrame(frame);
  }

  @Override
  public void addTimeScore(long ms, long expectedMs) {
    super.addTimeScore(ms, expectedMs);
    this.levelScores.get(this.lastLevel).addTimeScore(ms, expectedMs);
  }
}
